package spindles.api.domain;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.sleepycat.persist.model.Persistent;

@Persistent
public class SpindleIndication extends Spindle {

	/**
	 * 
	 */
	private static transient final long serialVersionUID = 6525660286217692454L;

	private static transient final DateFormat df = new SimpleDateFormat(
			"HH:mm:ss.SS");

	private long groupID;

	private boolean withSoftCriterion;

	public SpindleIndication(ThresholdGroup group, Date from, Date to,
			boolean withSoftCriterion) {
		super(from, to);
		this.groupID = group.getId();
		this.withSoftCriterion = withSoftCriterion;
	}

	public SpindleIndication(ThresholdGroup group, Date from, Date to) {
		this(group, from, to, false);
	}

	public SpindleIndication() {
		super();
	}

	protected String dateToString(Date date) {
		return df.format(date);
	}

	public boolean detectedWithSoftCriterion() {
		return withSoftCriterion;
	}

	public long getGroupID() {
		return groupID;
	}

	public int compareTo(Object o) {
		return CompareToBuilder.reflectionCompare(this, o);
	}

	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(17, 37, this);
	}

}
